﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QXBook.Utils;
using QXBook.Model;
using QXBook.Service;
using Web.App_Code;

namespace Web.Article
{
    public partial class Article_View : UserBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(CommonUtils.Get("ArticleID")))
                {
                    ArticleInfo article = ServiceFactory.CreateInstance<ArticleService>().GetModel(CommonUtils.Get("ArticleID"));
                    this.DataBind(article);
                }
            }
        }

        private void DataBind(IModelBase model)
        {
            ArticleInfo article = model as ArticleInfo;
            litTitle.Text = article.Title;
            litAddDate.Text = article.AddDate.ToString("yyyy-MM-dd");
            litContent.Text = article.Content;
        }
    }
}